package com.open.capacity.reimburse.controller;

import com.open.capacity.commons.Result;
import com.open.capacity.reimburse.exception.BusinessException;
import com.open.capacity.reimburse.service.StandardVerifyService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * 标准校验
 *
 * @author
 * @email
 * @date 2021-01-13 11:04:27
 */
@Slf4j
@RestController
@RequestMapping("standards")
@Api(tags = "标准校验")
public class StandardVerifyController {

    @Autowired
    private StandardVerifyService verifyService;

    /**
     * 校验数据
     */
    @RequestMapping("/verify")
    @PreAuthorize("hasAnyAuthority('std_hotel:stdhotel:verify')")
    public Result verify(String schemeinfoId, String processId, String keyValue, @RequestBody Map<String, Object> formData) {
        try {
            verifyService.verify(schemeinfoId, processId, keyValue, formData);
        } catch (BusinessException e) {
            return Result.failed(e.getMessage());
        } catch (Exception e) {
            log.error(e.toString());
        }
        return Result.succeed("校验成功");
    }
}
